package closure;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: fqtang
 * @date: 2024/12/21/6:48
 * @description: 闭包测试
 */
public class ClosureTest2 {

	public static void test(MyLambda lambda) {
		System.out.println(lambda.op(2));
	}

	//闭包作用：给函数对象提供参数以外的数据
	public static void main(String[] args) {
		//创建10个任务对象，并且每个任务对象给一个任务编号
		List<Runnable> tasks = new ArrayList<>();
		for(int i =0 ;i<10;i++){
			int finalI = i+1;
			tasks.add(()->{
				System.out.println("task:"+ finalI);
			});
		}
	}

	int a = 1;
	static int c = 1;

	public void test2() {
		int b = 1;
		test(y -> a + c);
	}

	static class Student {
        int age;

		public Student(int age) {
			this.age = age;
		}
	}
}
